var LoadHttp = (function (_super) {
    function LoadHttp(url) {
        LoadHttp.super(this);
        this.url=url; //url地址赋值
        this.xml; //request实例
        this.responseBuffer;
        Laya.URL.basePath="E:/Laya/zip_bag/";
        this.zipPath="http://domschool.cn/GameRes/Scenes.zip";
        this.localRes="E:/Laya/zip_bag/Scenes.zip"
        this.init(); //初始化

    }

    Laya.class(LoadHttp,"LoadHttp",_super);

    var _proto=LoadHttp.prototype;

    _proto.init=function()
    {
        this.load();
    }

    _proto.load=function()
    {
        this.xml=new XMLHttpRequest();
        this.xml.open("GET",this.localRes,true);

        this.xml.responseType="arraybuffer";
        this.xml.send();
        //arraybuffer
        this.xml.onreadystatechange=(function()
        {
            console.log("change");
        })
        

        //console.log(this.xml.getResponseHeader);
        Laya.timer.loop(10,this,this.loop);
    }

    _proto.loop=function()
    {
        console.log(this.xml.readyState);
       // console.log(this.xml.status);
        if(this.xml.readyState==4 )//&& this.xml.status==200)
        {
            this.LoadComplete();
        }
    }

    _proto.LoadComplete=function()
    {
      //  var a= Number(this.xml.getResponseHeader("Content-Length"));
        Laya.timer.clear(this,this.loop);
        this.responseBuffer=this.xml.response;
        console.log(this.responseBuffer);
        var a=this.responseBuffer;


        // var dataview=new DataView(this.responseBuffer);
        // var reader=new FileReader(this.url);
       this.textZlib(a);
       //this.transDateView();
    }

    _proto.transDateView=function()
    {
        var ab=new ByteArray(this.responseBuffer);
       // var a=this.responseBuffer
        ab.writeArraybuffer(this.responseBuffer);
        ab.uncompress();
        // var dataview=new DataView(this.responseBuffer);
        // this.textZlib(dataview);
    }


    _proto.textZlib=function(dview)
    {
        var a=new Uint8Array(dview);

        var unzip = new Zlib.Unzip(a);
        var filenames = unzip.getFilenames();
        var plain = unzip.decompress(filenames[4]);
        var i=0;
        var value="";
        for(i=0;i<plain.length;i+=8)
        {
             value+=String.fromCharCode(plain[i],plain[i+1],plain[i+2],plain[i+3],plain[i+4],plain[i+5],plain[i+6],plain[i+7]);
        }
        
        this.loadModel(filenames[4]);
        
    }

    _proto.loadModel=function(name)
    {
       var scene = Laya.Scene.load(name);
       Laya.stage.addChild(scene);
        


    }

   
     function downloadFile(url) {   
        try{ 
            var elemIF = document.createElement("iframe");   
            elemIF.src = url;   
            elemIF.style.display = "none";   
            document.body.appendChild(elemIF);   
        }catch(e){ 
            console.log(e);
 
        } 
    }
    
        
    }


   
    return LoadHttp;
})(Laya.Script);